import React, { Component } from 'react';
import axios from 'axios';

export default class App extends Component {
  getStudentData = () => {
    axios.get('/api/students').then(
      res => {
        console.log('学生成功', res);
      },
      error => {
        console.log('学生失败', error);
      }
    );
  };

  getCarData = () => {
    axios.get('/api1/cars').then(
      res1 => {
        console.log('car成功', res1);
      },
      err1 => {
        console.log('car失败', err1);
      }
    );
  };

  render() {
    return (
      <div>
        <button onClick={this.getStudentData}>点击我获取学生信息</button>
        <button onClick={this.getCarData}>点击我获取汽车信息</button>
      </div>
    );
  }
}
